import React, { Component } from 'react';
import { connect } from 'react-redux';
import User from '../../components/User';
import getUserList from '../../actions/user';

class UserList extends Component {
    constructor(props) {
        super(props);
    }

    render() {
        const { userInfo, bindClick } = this.props;
        console.log(this.props);
        return (
            <div>
                <User 
                    userInfo = { userInfo }
                    bindClick={ bindClick }
                />
            </div>
        )
    }
}

const mapStateToProps = state => {
    console.log(state);
    return {
        userInfoA: state.userInfo
    }
}
/*
const mapDispatchToProps = dispatch => ({
    
    bindClick: () => dispatch(getUserList({ type: "GETUSERLIST", name: "fangming", age: 45 }))

})

*/
const mapDispatchToProps = (dispatch) => {
  return {
    bindClickB: () => {
      dispatch(getUserList({ type: "GETUSERLIST", name: "fangming", age: 45 }))
    }
  }
}

export default connect(
    mapStateToProps,
    mapDispatchToProps
)(UserList)